<template>
    <van-nav-bar
        title="标题"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
    />
    <van-cell-group inset>
        <van-field v-model="nickname" label="昵称" />
    </van-cell-group>
    <van-button size="small" type="primary" @click="storage">保存</van-button>
</template>

<script setup>
import {useStore} from "../../pinia/index.js";
import {ref} from "vue";
import {get} from "../../util/request.js";
import {showToast} from "vant";
const storeUser=useStore();
let user = ref({});
const nickname=ref(storeUser.user.nickname);
const onClickLeft = () => history.back();
const storage = ()=>{
    get("user/editNickname",{nickname:nickname.value}).then(res=>{
        if (res.code === 0){
            user.value=res.data
            storeUser.setUser(res.data)
            console.log(user)
            console.log(JSON.stringify(storeUser))
        } else {

        }
    })
}
</script>

<style scoped>

</style>